<?php

declare (strict_types=1);

namespace App\Model;

use Carbon\Carbon;
use Hyperf\Database\Model\Collection;
use Hyperf\Database\Model\Relations\BelongsToMany;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;

/**
 * @property int $id
 * @property string $username
 * @property string $sign
 * @property string $code
 * @property string $avatar
 * @property string $status
 * @property string $identity
 * @property Carbon $updated_at
 * @property Carbon $created_at
 * @property-read Collection|FriendGroup[] $friendGroups
 */
class User extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'username', 'sign', 'code', 'avatar', 'status', 'identity', 'updated_at', 'created_at'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'updated_at' => 'datetime', 'created_at' => 'datetime'];

    public function friendGroups(): HasMany
    {
        return $this->hasMany(FriendGroup::class);
    }

    public function groups(): BelongsToMany
    {
        return $this->belongsToMany(Group::class);
    }
}